package mango.orm.entity;

import java.util.HashMap;
import java.util.List;

import mango.functions.FuncString;

public final class EntityCaches {
    private static final HashMap<String, List<Column>> ENTITY_COLUMNS = new HashMap<String, List<Column>>();
    private static final HashMap<String, String> ENTITY_TABLE = new HashMap<String, String>();
    
    public static List<Column> getColumns(String entityName) {
        return ENTITY_COLUMNS.get(entityName);
    }
    
    public static String getEntityTable(String entityName) {
        return ENTITY_TABLE.get(entityName);
    }
    
    public synchronized static void putEntity(String entityName, String tableName, List<Column> columns) {
        if (FuncString.isBlank(ENTITY_TABLE.get(entityName))) {
            ENTITY_COLUMNS.put(entityName, columns);
            ENTITY_TABLE.put(entityName, tableName);
        }
    }
}
